package bank.driver.soap;

import java.io.IOException;

import bank.Account;
import bank.InactiveException;
import bank.OverdrawException;
import bank.driver.soap.jaxws.BankService;
import bank.driver.soap.jaxws.IOException_Exception;
import bank.driver.soap.jaxws.IllegalArgumentException_Exception;
import bank.driver.soap.jaxws.InactiveException_Exception;
import bank.driver.soap.jaxws.OverdrawException_Exception;

final public class SOAPAccount implements Account {

	private BankService port;

	private String number;

	public SOAPAccount(BankService port2, String number) {
		this.port = port2;
		this.number = number;
	}

	@Override
	public void deposit(double amount) throws IOException, IllegalArgumentException, InactiveException {
		try {
			port.deposit(number, amount);
		} catch (IOException_Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException_Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InactiveException_Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Override
	public double getBalance() throws IOException {
		try {
			return port.getBalance(number);
		} catch (IOException_Exception e) {
			return 0.0;
		}
	}

	@Override
	public String getNumber() throws IOException {
		return number;
	}

	@Override
	public String getOwner() throws IOException {
		try {
			return port.getOwner(number);
		} catch (IOException_Exception e) {
			return null;
		}
	}

	@Override
	public boolean isActive() throws IOException {
		try {
			return port.isActive(number);
		} catch (IOException_Exception e) {
			e.printStackTrace();
			return false;
		}
	}

	@Override
	public void withdraw(double amount) throws IOException, IllegalArgumentException, OverdrawException, InactiveException {
		try {
			port.withdraw(number, amount);
		} catch (IOException_Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException_Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InactiveException_Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (OverdrawException_Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
